<?php

//前台用户控制器
//引入“命名空间”
namespace Home\Controller;
use Think\Controller;

class UserController extends Controller{
	function login(){

		$this->display();
	}
	public function checklog(){
  		if(isset($_POST['username'])){
  			$username=$_POST['username'];
  		}
  		$pwd=$_POST['password'];
  		$m=M("user");
  		$msg=$m->where("username='$username'")->find();
  		if($msg['password']==$pwd){
  			setcookie("username",$username);
  			
  			$this->success("登陆成功","./ucenter1");
  		}else{
  			$this->error("用户名或密码错误");
  		}
  	}
	//用户注册
	function register(){
		
        $this->display();   
    }
    
    public function checkreg(){

        $data['username']=$_POST['username'];
        $data['password']=$_POST['password'];
        $data['user_email']=$_POST['user_email'];
        $data['user_sex']=$_POST['user_sex'];
        $data['user_qq']=$_POST['user_qq'];
        $data['user_tel']=$_POST['user_tel'];
        $data['user_xueli']=$_POST['user_xueli'];
        $data['user_hobby']=$_POST['user_hobby'];
        $data['user_introduce']=$_POST['user_introduce'];
       
        $m=M("user");
        $msg=$m->create($data);
        $result=$m->add();
        if($result==true){
            setcookie("username",$data['username']);
            //$this->success("注册成功","/tmall/index.php/Home/");
        }else{
            //$this->error("注册失败");
        }
    } 
    public function ucenter1(){
    	$this->display();
    }
}









